home *** CD-ROM | disk | FTP | other *** search
/ Programmer Power Tools / Programmer Power Tools.iso / progjrn / pj_6_6.arc / ENABA20.ASM < prev    next >
Assembly Source File  |  1988-08-03  |  2KB  |  54 lines

  1. ;-----------------------------------------------------------------------------
  2. ; EnabA20.asm - by Jake Richter (& IBM) 07/13/88
  3. ;
  4. ; This routine enables Address Line 20 from the 80X86 processor when making
  5. ; memory references. Default is to drive A20 low, i.e. A20 disabled.
  6. ; The line state is controlled by the 8042 Keyboard Controller.
  7. ;
  8. ; Made executable with the following sequence:
  9. ;
  10. ; MASM EnabA20;
  11. ; LINK EnabA20;
  12. ; EXE2BIN EnabA20 EnabA20.com
  13. ;
  14. ;
  15. COM8042    equ     064H
  16. DAT8042    equ     060H
  17.  
  18.  
  19.  
  20. Cseg       segment
  21.            assume  CS:Cseg, DS:Cseg
  22.            org     100H                    ; Needed for COM file.
  23. Gate20     proc    near
  24.            cli                             ; Disable interrupts.
  25.            call    WaitOn8042              ; Make sure 8042 input buff is empty.
  26.            jnz     Gate20_Ret              ; Leave if command not accepted.
  27.            mov     AL, 0D1H                ; 8042 CMD -> Write Output Port
  28.            out     COM8042, AL             ; Send command to 8042.
  29.            call    WaitOn8042              ; Wait for 8042 to ACK.
  30.            jnz     Gate20_Ret              ; If it doesn't, exit.
  31.            mov     AL, 0DFH                ; Grab A20 enable value.
  32.                                            ; To disable, use 0DDH instead.
  33.            out     DAT8042, AL             ; Send it.
  34.            call    WaitOn8042              ; Wait for 8042 one last time.
  35.            sti                             ; Restore interrupts.
  36. Gate20_Ret:
  37. ;          cmp     AL, 0                   ; Implement if error check
  38. ;                                          ; is needed...
  39. ;          jne     DidNotWork
  40.            ret                             ; Return to DOS.
  41. Gate20     endp
  42.  
  43. WaitOn8042 proc    near
  44.            xor     CX, CX                  ; Clear timeout counter.
  45. WaitLoop:
  46.            in      AL, COM8042             ; Read 8042 status.
  47.            and     AL, 02                  ; Test for input buffer full.
  48.            loopnz  WaitLoop                ; Wait until timeout or OK.
  49.            ret
  50. WaitOn8042 endp
  51.  
  52. Cseg       ends
  53.            end
  54.